package springBoot;

import common.Result;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.jms.Queue;
import javax.jms.Topic;

/**
 * Created by lx on 2017/6/30.
 */

@Controller
@EnableAutoConfiguration
@ComponentScan(basePackages = {"springBoot"})
public class HelloSpringBoot {
    @Autowired
    private MyProps myProps;

    @RequestMapping("/")
    @ResponseBody
    public String helloWord(){
        return "hello spingBoot";
    }

    @Bean("topic")
    public Topic topic(){
        return new ActiveMQTopic("sample.topic");
    }

    @Bean("queue")
    public Queue queue(){
        return new ActiveMQQueue("sample.queue");
    }

    @RequestMapping("/getMyProps")
    @ResponseBody
    public Result<MyProps> getMyProps(){
        return Result.sucess(myProps);
    }

    public static void main(String[] args) {
        SpringApplication.run(HelloSpringBoot.class,args);
    }
}
